require(['./config'], () => {
    require(['template', 'header', 'footer', 'jquery'], (template) => {
        class Goods {
            constructor() {
                this.a()
                this.b()
                this.c()
                this.d()
            }
            a() {
                $.get('http://www.xiongmaoyouxuan.com/api/tabs', resp => {
                    if (resp.code === 200) {
                        let { list } = resp.data
                        list = list.slice(8, 15)
                        $('#tabList').html(template('tabListTp', { list }))
                    }
                })
            }
            b() {
                $.get('http://www.xiongmaoyouxuan.com/api/tab/1', resps => {
                    if (resps.code === 200) {
                        let { gridsV3 } = resps.data
                        let { list } = resps.data.items
                        let { note } = resps.data
                        list = list.filter(shop => shop.qunTitle)
                        console.log(resps)
                        console.log(list)
                        $('#remen').html(template('remenhot', { gridsV3 }))
                        $('#note').html(template('notelist', { note }))
                    }
                })
            }
            c() {
                $.get('http://www.xiongmaoyouxuan.com/api/tab/2', resps => {
                    let { list } = resps.data.items
                    let { hotCommodities, title, price, } = resps.data
                    let id = location.search.slice(4)
                    if (hotCommodities.length > 3) {
                        hotCommodities.length = 3
                    }
                    if (list.length > 18) {
                        list.length = 18
                    }
                    $('#fbmain').html(template('fbtemplate', { list }))
                    $('#grids').html(template('scgrids', { hotCommodities, title, price, }))
                    $(function () {
                        $("#grids").on("mouseenter", "div", function () {
                            $(this).animate({
                                opacity: '0.8',
                            }, 500).mouseleave(function () {
                                $(this).animate({
                                    opacity: '1',
                                }, 0)
                                return false
                            })
                        })
                    });
                })
            }
            d() {
                $(function () {
                    $('#btnsou').on('click', function () {
                        $('.shadebox').fadeIn(100)
                        let render = $('input,.inputbox').val()
                        $('.shadeboxtwo').append(`<b class="sb">${render}</b>`)
                    })
                    $('.close').on('click', function () {
                        $('.shadebox').fadeOut(200)
                        $('input,.inputbox').val(null)
                        $('.sb').remove()
                    })
                    $('.searchlf').on('focus', 'input', function () {
                        $(this).css("background", "#cccccc30");
                    }).on('blur', 'input', function () {
                        $(this).css("background", "#ffffff");
                    })
                })
            }
        }
        return new Goods()
    })
})